package com.example.service;

import cn.hutool.core.date.DateUtil;
import com.example.dao.CarouselDao;
import com.example.dao.NoticeDao;
import com.example.pojo.Carousel;
import com.example.pojo.Notice;
import com.example.pojo.Params;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;


@Service
public class CarouselService {

    @Resource
    private CarouselDao carouselDao;


    public void add(Carousel carousel) {
        carouselDao.insertSelective(carousel);
    }

    public PageInfo<Carousel> findAll(Params params) {
        // 开启分页查询
        PageHelper.startPage(params.getPageNum(), params.getPageSize());
        // 接下来的查询会自动按照当前开启的分页设置来查询
        List<Carousel> list = carouselDao.findAll(params);
        return PageInfo.of(list);
    }

    public void update(Carousel carousel) {
        carouselDao.updateByPrimaryKeySelective(carousel);
    }

    public void delete(Integer id) {
        carouselDao.deleteByPrimaryKey(id);
    }

}